package com.labofjet.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Order(AspectOrder.LOG_ORDER)
public class LogAspect extends BaseLogAspect{
	
	private static final Logger LOGGER = LoggerFactory.getLogger(LogAspect.class);
	
	@Around(value = "within(@org.springframework.stereotype.Controller *)", argNames = "param")
	public Object controllerLog(ProceedingJoinPoint pjp) throws Throwable{
		LOGGER.info("执行 {} 的方法,参数为{}", pjp.getSignature().toString(), pjp.getArgs());
		Object obj = pjp.proceed();
		LOGGER.info("执行 {} 的方法成功, 返回数据为{}", pjp.getSignature().toString(), obj);
		return obj;
	}
	
	//@Around(value = "within(@org.springframework.stereotype.Service *)", argNames = "param")
	public Object serviceLog(ProceedingJoinPoint pjp) throws Throwable{
		LOGGER.info("执行 {} 的方法,参数为{}", pjp.getSignature().toString(), pjp.getArgs());
		Object obj = pjp.proceed();
		LOGGER.info("执行 {} 的方法成功, 返回数据为{}", pjp.getSignature().toString(), obj);
		return obj;
	}

}
